Add net11 span white-space search APIs - #586
Merged
Merged
Conversation
Adds the white-space searches on ReadOnlySpan<char>: * ContainsAnyWhiteSpace() * IndexOfAnyWhiteSpace() * IndexOfAnyExceptWhiteSpace() * LastIndexOfAnyWhiteSpace() * LastIndexOfAnyExceptWhiteSpace() The white-space set was checked against net11 over the whole BMP and matches char.IsWhiteSpace on every code point, so the implementation is a straight scan using it. Empty spans return false and -1, matching net11. Placed in their own Polyfill_Memory_WhiteSpace.cs, following the existing split of Polyfill_Memory.
This was referenced Sep 10, 2026
This was referenced Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the white-space searches added to
ReadOnlySpan<char>in net11:ContainsAnyWhiteSpace()IndexOfAnyWhiteSpace()IndexOfAnyExceptWhiteSpace()LastIndexOfAnyWhiteSpace()LastIndexOfAnyExceptWhiteSpace()API count 1047 to 1052.
Semantics
The white-space set was checked against net11 across the whole BMP and matches
char.IsWhiteSpaceon every code point, so the implementation is a straight scan using it rather than a hardcoded set. Empty spans returnfalseand-1, matching net11.The BCL versions are vectorised and these are not, but both are O(n) and the results are identical, so no
//Note:was added.Placement
In their own
Polyfill_Memory_WhiteSpace.cs, following the existing split ofPolyfill_MemoryintoPolyfill_Memory_StartsWith.cs,Polyfill_Memory_EndsWith.csand so on. That also keeps this clear of #585, which touches the end ofPolyfill_Memory.cs, so the two can merge in either order.Note that
MemoryExtensions.IsWhiteSpace(ReadOnlySpan<char>)is not included: it already ships inSystem.Memory, so it is available whereverFeatureMemoryis set.Verification
Consumebuilds clean in Debug across all 22 target frameworks.PublicTests,EmbeddedTests,UnsafeTests,NoRefsTestsandNoExtrasTests.